package cn.school.thoughtworks.section1;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class PracticeB {
    List<String> collectSameElements(List<String> collection1, List<List<String>> collection2) {
        //实现练习要求，并改写该行代码。
        List<String> returnList = new ArrayList<>();
        for(List<String> list:collection2){
            returnList.addAll(collection1.stream().filter(list::contains).collect(Collectors.toList()));
        }
        return returnList.stream().distinct().collect(Collectors.toList());
    }
}
